//_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/.
// 			VisualNovelToolkit		     /_/_/_/_/_/_/_/_/_/.
// Copyright ©2013 - Sol-tribe.	/_/_/_/_/_/_/_/_/_/.
//_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/.

using UnityEngine;
using System.Collections;

/// <summary>
/// Script engine behaviour.
/// </summary>
public class ScriptEngineBehaviour : MonoBehaviour{	
	/// <summary>
	/// Back Log Item Max.
	/// </summary>
	public int m_BackLogLimit = 20;

	/// <summary>
	/// Enabled Vino's Debug.Log is enabled.
	/// </summary>	
	public bool m_EnableVinoDebugLog;

	/// <summary>
	/// On Level Was Loaded and Back Log is cleared. 
	/// </summary>	
	public bool loadLevelAndClearBackLog = true;

	/// <summary>
	/// if true , the Passed label is set to true to a flag table.
	/// </summary>
	public bool checkPassedLabelToFlagTable = true;

	protected IScriptBinder m_ScriptBinder;	

	/// <summary>
	/// if true , Text Auto Mode is enabled.
	/// </summary>
	static protected bool m_AutoMode;
	static public bool autoMode{
		get{
				return m_AutoMode;
		}
		set{
				m_AutoMode = value;
				VM.autoMode = value;
		}
	}

	static protected float m_AutoModeWaitSec = 0.3f;

	/// <summary>
	/// It is expected that the Value is 0.f ~ 1.f .
	/// </summary>	
	static public float autoModeWaitTime{
		get{	
				return m_AutoModeWaitSec;
		}
		set{
				VM._AUTO_MODE_WAIT_TIME = value;
				m_AutoModeWaitSec =VM._AUTO_MODE_WAIT_TIME;
		}
	}	

	/// <summary>
	/// if true , Text Skip Mode is enabled.
	/// </summary>
	static public bool skip{ get; set; }

	/// <summary>
	/// if true , the Message Already Read will be Skip.
	/// </summary>
	static public bool skipAlreadyPass{ get; set; }	

	[HideInInspector] public GameObject CURRENT;

	void SetCurrentNodeObject( GameObject currentNode ){
		CURRENT = currentNode;
	}
	
	// Debug Log Tag Info.
	protected class LogTag{
		public string 	tag;		// NGUIEx or  VM or .. 
		public bool	enable;	// Is this tagged show in Console Log ?.
		public LogTag( string _tag , bool _enable) {
			tag = _tag;
			enable = _enable;
		}
	}
	protected LogTag[] tags;

	static protected bool m_LockNextMessage;
	static public bool isLockNextMessage{
		get{ return m_LockNextMessage; }
	}

	static public void LockNextMessage(){
		m_LockNextMessage = true;
	}

	static public void UnlockNextMessage(){
		m_LockNextMessage = false;		
	}
	
	static public int backLogLimit{
		set; get;	
	}
			
	protected void Init(){
		// Set Debug Log Info.
		SetLogTag();
		
		// Set the BackLog String Limit.
		backLogLimit =m_BackLogLimit;
		
	}	
	
	protected void SetLogTag( ){
		ViNoDebugger.m_LogEnabled = m_EnableVinoDebugLog;
		if( m_EnableVinoDebugLog ){
			tags = new LogTag[ 13 ];
			tags[ 0 ] = new LogTag( "NGUIEx" , false );
			tags[ 1 ] = new LogTag( "NGUIBind" , false );
			tags[ 2 ] = new LogTag( "VM" , true );
			tags[ 3 ] = new LogTag( "Sound" , true );
			tags[ 4 ] = new LogTag( "DialogPartEvent" , true );
			tags[ 5 ] = new LogTag( "NODE" , true );
			tags[ 6 ] = new LogTag( "Compile" , true );
			tags[ 7 ] = new LogTag( "SaveInfo" , true );
			tags[ 8 ] = new LogTag( "SELECTION" , true );						
			tags[ 9 ] = new LogTag( "INPUT" , true );						
			tags[ 10 ] = new LogTag( "GO" , true );						
			tags[ 11 ] = new LogTag( "ANIMATION" , true );						
			tags[ 12 ] = new LogTag( "SystemUIEvent" , true );						
			for( int i=0;i<tags.Length;i++){
				ViNoDebugger.EnableTag( tags[ i ].tag, tags[ i ].enable );
			}
		}
	}		
				


}
